<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <style>
      div#errors {
        border: solid 1px red;
        color: red;
        display: block;
      }
      div#errors:empty {
        display: none !important;
      }
    </style>
    <div id="errors"></div>
    <form action="http://baidu.com" onsubmit="return onSubmit()">
      手机号: <input type="text" name="mobile" />
      <button>提交</button>
    </form>
    <script>
      function onSubmit() {
        let input = document.querySelector('input[name="mobile"]').value.trim()
        if (input == false) {
          message('手机号不能为空')
        }
        return false
      }

      function message(message) {
        let container = document.querySelector('#errors')
        container.innerHTML = message
      }
      //String boolean
      // 0   0
      //   if (false === false) {
      //     console.log('成立')
      //   }

      //   let str = 'abc'
      //   Array(str).map((v) => console.log(v))

      //   let n = 34
      //   console.log(typeof String(n))

      //   function show() {
      //     console.log('show...')
      //   }
    </script>
  </body>
</html>